import pandas as pd
df1 = pd.read_csv(r'C:\Users\Wang\Desktop\data\stock_small.csv')
df = df1.iloc[:, [1, 2, 7]]  #<股票代码>  <年月日>  <交易数量>

df['date'] = pd.to_datetime(df['date'])
df['date.y'] = df['date'].dt.year
new_series = df.groupby(by=['stock_symbol','date.y']).sum('stock_volume')

new_series = new_series.sort_values(by="stock_volume", ascending=False)

print(new_series)